Skip to main content

Biometric Capture

Add Biometric Capture to Application

Use the CaptureSessionFragment to add the required elements to an activity

// MainActivity.java
private CaptureSessionFragment captureSession;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

this.captureSession = (CaptureSessionFragment) getSupportFragmentManager().findFragmentById(R.id.mob_capture_session);
}
<!-- activity_main.xml -->
<fragment android:name="bio.mobai.library.capture.CaptureSessionFragment"
android:id="@+id/mob_capture_session"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_height="200dp"
android:layout_width="200dp"
/>

Start Camera Preview

Start the camera preview after the camera permissions are obtained

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

this.captureSession.setupCaptureSession();
}

Start capture session

Run the capture session and wait for the payload

this.captureSession.startCaptureSession(sessionPayload -> {
// Use session payload
}

(Optional) Configure a Capture Session

The capture session can be configured with the following parameters

CaptureSessionFragment captureSession = (CaptureSessionFragment) getSupportFragmentManager().findFragmentById(R.id.mob_capture_session);
captureSession.setEncoding(Bitmap.CompressFormat.JPEG);
captureSession.setFaceCaptureEnabled(true);
captureSession.setNumFramesBeforeFaceImage(9);
captureSession.setPadCaptureEnabled(true);
captureSession.setNumFramesPad(5);
captureSession.setFrameInterval(4);
captureSession.setTargetResolutionPad(new Size(720, 1280));
captureSession.setFaceQualityEnabled(true);